package config;

import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import java.util.ArrayList;
import java.util.List;

public class SentinelInitRule {
    public static void initFlowRules(){
        List<FlowRule> rules = new ArrayList<>();
        FlowRule rule = new FlowRule();
        rule.setResource("getHotSearch");    //资源名称
        rule.setGrade(RuleConstant.FLOW_GRADE_QPS);
        rule.setCount(50);    //每秒通过的请求数50
        rules.add(rule);
        FlowRuleManager.loadRules(rules);
    }
}
